﻿<Window x:Class="PizzaService.View.EditCustomerWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:c="clr-namespace:PizzaService.BindValidation"
        Title="Kunde" Height="400" Width="400" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
    <Window.Background>
        <RadialGradientBrush>
            <GradientStop Color="#FFCF5454" Offset="0"/>
            <GradientStop Color="#FFA41B1B" Offset="1"/>
        </RadialGradientBrush>
    </Window.Background>
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Styles\Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}" BasedOn="{StaticResource CustomTextBoxStyle}">
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip"
              Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                              Path=(Validation.Errors)[0].ErrorContent}"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        </ResourceDictionary>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Label Grid.Row="0" Content="Name:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="1" Content="Vorname:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="2" Content="Straße:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="3" Content="Hausnummer:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="4" Content="PLZ:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="5" Content="Ort:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="6" Content="Telefon:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <Label Grid.Row="7" Content="E-Mail:" HorizontalAlignment="Left" Margin="20,5,0,5" Style="{StaticResource CustomLabelStyle}"></Label>
        <TextBox Name="TxtName" Grid.Row="0" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Text="{Binding Name, Mode=TwoWay}" Style="{StaticResource CustomTextBoxStyle}"></TextBox>
        <TextBox Name="TxtVorname" Grid.Row="1" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Text="{Binding Vorname, Mode=TwoWay}" Style="{StaticResource CustomTextBoxStyle}"></TextBox>
        <TextBox Name="TxtStrasse" Grid.Row="2" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Text="{Binding Strasse, Mode=TwoWay}" Style="{StaticResource CustomTextBoxStyle}"></TextBox>
        <TextBox Name="TxtHausnummer" Grid.Row="3" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Style="{StaticResource textBoxInError}">
            <Binding
        Path="Hausnummer"
        Mode="TwoWay"
        UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <c:ValidateHouseNumber/>
                </Binding.ValidationRules>
            </Binding>
        </TextBox>
        <TextBox Name="TxtPLZ" Grid.Column="1" Grid.Row="4" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Style="{StaticResource textBoxInError}">
            <Binding
        Path="PLZ"
        Mode="TwoWay"
        UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <c:ValidatePLZ/>
                </Binding.ValidationRules>
            </Binding>
        </TextBox>
        <TextBox Name="TxtOrt" Grid.Column="1" Grid.Row="5" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Text="{Binding Ort, Mode=TwoWay}" Style="{StaticResource CustomTextBoxStyle}"></TextBox>
        <TextBox Name="TxtTelefonnummer" Grid.Column="1" Grid.Row="6" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Style="{StaticResource textBoxInError}">
            <Binding
        Path="Telefonnummer"
        Mode="TwoWay"
        UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <c:ValidatePhoneNumber/>
                </Binding.ValidationRules>
            </Binding>
        </TextBox>
        <TextBox Name="TxtMail" Grid.Column="1" Grid.Row="7" Width="200" Margin="0,0,20,0" HorizontalAlignment="Right" Style="{StaticResource textBoxInError}">
            <Binding
        Path="Mail"
        Mode="TwoWay"
        UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <c:ValidateMail/>
                </Binding.ValidationRules>
            </Binding>
        </TextBox>
        <Button Name="BtnOk" Grid.Column="1" Grid.Row="8" Content="OK" Width="80" HorizontalAlignment="Left" Click="BtnOk_Click_1" Margin="50,5,20,20">
            <Button.Style>
                <Style TargetType="{x:Type Button}" BasedOn="{StaticResource CustomButtonStyle}">
                    <Setter Property="IsEnabled" Value="false" />
                    <Style.Triggers>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding ElementName=TxtName, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtVorname, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtStrasse, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtHausnummer, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtPLZ, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtOrt, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtTelefonnummer, Path=(Validation.HasError)}" Value="false" />
                                <Condition Binding="{Binding ElementName=TxtMail, Path=(Validation.HasError)}" Value="false" />
                            </MultiDataTrigger.Conditions>
                            <Setter Property="IsEnabled" Value="true" />
                        </MultiDataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
        <Button Name="BtnCancel" Grid.Column="1" Grid.Row="8" Content="Cancel" Width="80" HorizontalAlignment="Right" Click="BtnCancel_Click_1" Margin="0,5,50,20" Style="{StaticResource CustomButtonStyle}"/>
    </Grid>
</Window>
